<template lang="pug">
el-dialog(
  :visible.sync="show"
  width="900px"
  top="5vh"
  @open="beforeOpen"
  :before-close="handleClose"
  custom-class="dialog-border"
  :close-on-click-modal="false"
)
  .modal-title(slot="title") 出入库记录
  .modal-content
    el-table(
      height="500px"
      :data="tableData"
      :header-cell-style="{ fontSize: '14px', color: '#64698F', background: '#F8F7FC' }"
      border
      style="width: 100%"
      empty-text="未找到符合条件的内容"
    )
      el-table-column(align="center" min-width="60" label="操作内容")
        template(slot-scope="scope") {{scope.row.type | filterSampleType}}
      el-table-column(align="center" min-width="60" label="操作人" prop="createByName")
      el-table-column(align="center" min-width="60" label="库存量" prop="stock")
      el-table-column(align="center" min-width="60" label="操作时间")
        template(slot-scope="scope") {{new Date(scope.row.createTime).format('yyyy-MM-dd hh:mm:ss')}}
</template>

<script>
import { getSampleStockLog } from 'api'
export default {
  name: 'sampleRecordModal',
  props: {
    show: Boolean,
    item: Object
  },
  data () {
    return {
      tableData: []
    }
  },
  methods: {
    beforeOpen () {
      this.getList()
    },
    async getList () {
      try {
        const { ResultSet } = await this.$axios.post(getSampleStockLog, { id: this.item.materialsSampleId })
        this.tableData = ResultSet.userData.stockList
      } catch (err) {
        console.log(err)
        this.$message.error(err.message || err.ResultSet.errors)
      }
    },
    handleClose () {
      this.$emit('close')
    }
  },
}
</script>

<style lang="scss" scoped>

</style>